<?php

/**
 * Comprobante form base class.
 *
 * @method Comprobante getObject() Returns the current form's model object
 *
 * @package    sf_sandbox
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseComprobanteForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                  => new sfWidgetFormInputHidden(),
      'fecha_emision'       => new sfWidgetFormDateTime(),
      'nro_comprobante'     => new sfWidgetFormInputText(),
      'importe_cuota'       => new sfWidgetFormInputText(),
      'unidad_funcional_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('UnidadFuncional'), 'add_empty' => false)),
      'tipo_comprobante_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TipoComprobante'), 'add_empty' => false)),
      'lectura_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Lectura'), 'add_empty' => true)),
      'categoria_agua_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('CategoriaAgua'), 'add_empty' => true)),
      'periodo_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Periodo'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id'                  => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'fecha_emision'       => new sfValidatorDateTime(),
      'nro_comprobante'     => new sfValidatorNumber(),
      'importe_cuota'       => new sfValidatorNumber(array('required' => false)),
      'unidad_funcional_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('UnidadFuncional'))),
      'tipo_comprobante_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('TipoComprobante'))),
      'lectura_id'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Lectura'), 'required' => false)),
      'categoria_agua_id'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('CategoriaAgua'), 'required' => false)),
      'periodo_id'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Periodo'))),
    ));

    $this->widgetSchema->setNameFormat('comprobante[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Comprobante';
  }

}
